package hsb.ruoyi.system.mapper;

import hsb.ruoyi.common.core.domain.entity.AppUser;
import hsb.ruoyi.common.mybatisplus.CustomBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * app用户Mapper接口
 *
 * @author ruoyi
 * @date 2022-08-22
 */
@Mapper
public interface AppUserMapper extends CustomBaseMapper<AppUser> {
    /**
     * 查询app用户
     *
     * @param id app用户主键
     * @return app用户
     */
    AppUser selectAppUserById(Long id);

    /**
     * 查询app用户列表
     *
     * @param appUser app用户
     * @return app用户集合
     */
    List<AppUser> selectAppUserList(AppUser appUser);

    /**
     * 新增app用户
     *
     * @param appUser app用户
     * @return 结果
     */
    int insertAppUser(AppUser appUser);

    /**
     * 修改app用户
     *
     * @param appUser app用户
     * @return 结果
     */
    int updateAppUser(AppUser appUser);

    /**
     * 删除app用户
     *
     * @param id app用户主键
     * @return 结果
     */
    int deleteAppUserById(Long id);

    /**
     * 批量删除app用户
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteAppUserByIds(Long[] ids);


    @Select("select * from app_user where openid=#{openid} limit 1")
    AppUser selectByopenid(String openid);

    @Select("select * from app_user where phone=#{phone} limit 1")
    AppUser selectByPhone(String phone);

    @Update("update `app_user` SET  password=#{newPwd} where id=#{userId}")
    int resetUserPwd(String newPwd, Long userId);
}
